/******************************************************************************
 * Copyright (C), 2000-2014,  Frank.
 * filename: blast.h
 * Author: Frank
 * Version:
 * Data: 2014-12-9 
 * brief:
 ******************************************************************************/
#ifndef _BLAST_H_
#define _BLAST_H_

#include <CoOS.h>			                 /*!< CoOS header file            */
#include "NUC123.h"

#define BLAST_PROTOCOL_UNKNOW	255
#define BLAST_PROTOCOL_NEC		0
#define BLAST_PROTOCOL_RC6		1		

//NEC using recognition
//P: plus, S: space
//Header 9000P+4500S
//Repeat 9000P+2250S+560P
//Logic 1 560P+1120S
//Logic 0 560P+560S
#define NEC_CODE_LEN		32		//32DATA
#define NEC_TOLERRANCE		40
#define NEC_HEADER_PLUS	9000
#define NEC_HEADER_SPACE	4500
#define NEC_REPEAT_SPACE	2250
#define NEC_REPEAT_PLUS	560
#define NEC_BIT0_PLUS		560
#define NEC_BIT0_SPACE		560
#define NEC_BIT1_PLUS		560
#define NEC_BIT1_SPACE		1120

//RC6 using recognition
//P: plus, S: space
//Header 2666+889
//Logic1 P-S
//logic0 S-P
//normal bit 444us phase, 444*2 one bit
//Trailer bit 888us phase,888*2 one bit
#define RC6_CODE_LEN		21	// 1SB+3MB+1TR+16DATA
#define RC6_TOLERRANCE		20	
#define RC6_HEADER_PLUS	2666
#define RC6_HEADER_SPACE	889
#define RC6_BITPHASE		444

void Blast_Init(void);
void Blast_WritePlus(U32 u32Plus);
BOOL Blast_ReadPlus(U32 *pu32Plus);
BOOL Blast_DoDecode(U8 *pu8Protocol, U32 *pu32Code);
void Blast_ExitDecode(void);
U16 Blast_GetPlusNum(void);


#endif

